package utils;

/*
 * Basic pair utility class.
 */
public class IntPair implements Comparable<IntPair >{
	private int first;
	private int second;
	
	public IntPair(int first, int second) {
		this.first = first;
		this.second = second;
	}
	
	public int getFirst() {
		return first;
	}
	
	public int getSecond() {
		return second;
	}
	
	public int compareTo(IntPair other) {
		int comp = first - other.first;
		
		if (comp != 0) {
			return comp;
		} else {
			return second - other.second;
		}
	}
	
	public boolean equals(Object other) {
		return compareTo((IntPair)other) == 0;
	}
	
	public int hashCode() {return toString().hashCode();}
	
	public String toString() {
		return "<" + first + " , " + second + ">";
	}

	public int[] toArray() {
		return new int[] {first, second}; 
	}
}
